package com.kalua.list.domainmodel.retailer;

import java.util.Arrays;

import com.kalua.list.domainmodel.TextIdentifier;


public class RetailerImpl implements Retailer {
	
	private static final long serialVersionUID = 198842249320951847L;

	private TextIdentifier id;
	private String tradingName;
	private String logoURI;

	private RetailerImpl() { }
	
	public RetailerImpl(	TextIdentifier id, 
									String tradingName, 
									String logoURI) {
		this();
		setId(id);
		setTradingName(tradingName);
		setLogoURI(logoURI);
	}
	
	@Override
	public TextIdentifier getId() { return this.id; }
	private void setId(TextIdentifier id) { this.id = id;}

	@Override
	public String getTradingName() { return this.tradingName;}
	private void setTradingName(String tradingName) 
	{ this.tradingName = tradingName; }
	
	@Override
	public String getLogoURI() { return this.logoURI; }
	public void setLogoURI(String logoURI) { this.logoURI = logoURI;}
	
	@Override
	public String toString() 
	{ return String.valueOf(this.id) + "( " + getTradingName() + ")";  }
	
	@Override
	public int hashCode() { return this.id.hashCode(); }
	
	@Override
	public boolean equals(Object obj) {
		boolean result = false;
		if (this == obj)
			result = true;
		else if (obj!=null && getClass().isInstance(obj)) {
			RetailerImpl other = (RetailerImpl) obj;
			Object[] fields = new Object[]{this.id, this.tradingName, this.logoURI};
			Object[] otherFields = new Object[]{other.id, other.tradingName, other.logoURI};
			result = Arrays.equals(fields,otherFields);
		}
		return result;
	}
}